package com.tanglon.controller;


import com.tanglon.service.ExcelReadService;
import com.tanglon.service.ExcelWriteService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/test/read")
public class TestController {

    @Resource
    private ExcelReadService excelReadService;

    @Resource
    private ExcelWriteService excelWriteService;

    @PostMapping("/demo")
    public void read(@RequestParam("file") MultipartFile file) {
        excelReadService.readSimpleExcel(file);
    }

    @PostMapping("/demo1")
    public void read1(@RequestParam("file") MultipartFile file) {
        excelReadService.readMultipartExcel(file);
    }

    @GetMapping("/export")
    public void read2(HttpServletResponse response) {
        excelWriteService.exportData(response);
    }
}
